﻿/*
 * 文件名称：
 * 程序员：huangsb
 * 创建时间：2008/05/20
 * 
 * 功能说明：帐号管理
 * 
 * 修改人员：
 * 
 * 修改日期：
 * 
 * 修改记录：
 */

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Whir.Common.WebHelper;
public partial class Whir_System_Module_Role_AdminList : System.Web.UI.Page
{
    protected string Action = "";
    protected int adminID = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        RoleHelper.IsLogin();    //登录判断

        Action = NetRequest.GetQueryString("action");
        adminID = NetRequest.GetQueryInt("id");
        if (RoleHelper.AdminCache.typeID != 1)
        {
            JsHelper.redirect(Page, "当前用户不是管理员，无法继续操作！", "../../Main.aspx");
            return;
        }

        if (Action == "delete")
        {
            Whir.BLL.Whir_AdminInfo adminBll = new Whir.BLL.Whir_AdminInfo();
            Whir.Model.Whir_AdminInfo adminModel = new Whir.Model.Whir_AdminInfo();
            adminModel = adminBll.GetModel(adminID);

            if (adminModel.adminID == 1 && adminModel.createUserID == 0)
            {
                JsHelper.Alert(Page, "当前不能删除管理员！");
            }
            else if (adminID == RoleHelper.AdminCache.adminID)
            {
                JsHelper.Alert(Page, "当前不能删除自身！");
            }
            else
            {
                adminBll.Delete(adminID);
                JsHelper.Alert(Page, "已成功删除此用户！");
            }
        }

        if (!IsPostBack)
        {
            BindData();
        }
    }

    protected void BindData()
    {
        DataTable dt = Whir.SQLServerDAL.DbHelperSQL.GetDataTable("*", "Whir_AdminInfo", "CreateUserID=" + RoleHelper.AdminCache.adminID + " OR adminID=" + RoleHelper.AdminCache.adminID, "");
        this.rAdmin.DataSource = dt.DefaultView;
        this.rAdmin.DataBind();
    }

    //类型
    protected string getTypeName(string tid)
    {
        return tid == "1" ? "超级管理员" : "普通管理员";
    }
}
